/**  
* @Title: HouseController.java
* @Package com.house.service.controller
* @version V1.0  
*/ 
package com.hjb.service.controller.user;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.hjb.service.annotation.LogInfo;
import com.hjb.service.annotation.LogType;
import com.hjb.service.domain.Collect;
import com.hjb.service.domain.Reservation;
import com.hjb.service.user.UserHouseService;

/**
* @ClassName: HouseController
* @Description: TODO(用户租房中心)
* @author <a href="mailto:125671254@qq.com">Pan Xinwen</a>
* @date 2017年4月28日 下午4:02:26
*/
@RestController
@RequestMapping("/userHouse/v1/")
public class UserHouseController {
 
	@Autowired
	private UserHouseService userHouseService;
	
	/**
	 * @Title: getcollectHouseByHouseId
	 * @Description: TODO(收藏/取消收藏)
	 * @param @param houseId
	 * @param @return    设定文件
	 * @return Map<String,Object>    返回类型
	 * @throws
	 */
	@LogInfo(logType=LogType.修改,operationContent="收藏/取消收藏(浏览记录)")
	@RequestMapping("collect")
	@ResponseBody
	public Map<String,Object> collectHouse(HttpServletRequest request, String houseId,String sign){
		String userId = request.getSession().getAttribute("userId")+"";
		userHouseService.collectHouse(userId, houseId,sign);
		return null;
		
	}
	
	/**
	* @Title: getcollectHouseByHouseId
	* @Description: TODO(查询房屋是否收藏)
	* @param @param houseId
	* @param @return    设定文件
	* @return Map<String,Object>    返回类型
	* @throws
	 */
	@LogInfo(logType=LogType.查询,operationContent="查询房屋是否收藏")
	@RequestMapping("isCollect")
	@ResponseBody
	public Collect getCollectHouseByHouseId(HttpServletRequest request,String houseId){
		String userId = request.getSession().getAttribute("userId")+"";
		return userHouseService.getCollectHouseByHouseId(userId, houseId);
		
	}
	
	/**
	 * 
	* @Title: getSubscribeByHouseId
	* @Description: TODO(预约看房/取消预约)
	* @param @param houseId
	* @param @param sign    设定文件
	* @return void    返回类型
	* @throws
	 */
	@LogInfo(logType=LogType.修改,operationContent="预约看房")
	@RequestMapping("subscribe")
	@ResponseBody
	public String subscribeByHouse(HttpServletRequest request, String reservationTime,String mobileNo,String memberName,String houseId,String sign,String rentNo,String roomNo){
		String userId = request.getSession().getAttribute("userId")+"";
		return userHouseService.subscribeByHouse(reservationTime,mobileNo,memberName,userId,houseId,sign,rentNo,roomNo)+"";
		
	}
	
	/**
	 * 查询房源是否被自己预约
	* @Title: isSubscribeByHouseId
	* @Description: TODO(查询房源是否被自己预约)
	* @param @param houseId
	* @param @return    设定文件
	* @return Reservation    返回类型
	* @throws
	 */
	@LogInfo(logType=LogType.查询,operationContent="查询是否预约")
	@RequestMapping("isubscribe")
	@ResponseBody
	public Reservation isSubscribeByHouseId(HttpServletRequest request, String houseId){
		String userId = request.getSession().getAttribute("userId")+"";
		return userHouseService.isSubscribeByHouseId(houseId,userId);
		
	}
	
	/**
	* @Title: getcollectHouseByHouseId
	* @Description: TODO(查询用户收藏的房源)
	* @param @param houseId
	* @param @return    设定文件
	* @return Map<String,Object>    返回类型
	* @throws
	 */
	@LogInfo(logType=LogType.查询,operationContent="查询用户收藏的房源")
	@RequestMapping("getCollects")
	@ResponseBody
	public List<Map<String,Object>> getCollectHouse(HttpServletRequest request){
		String userId = request.getSession().getAttribute("userId")+"";
		return userHouseService.getCollectHouse(userId);
		
	}
	
	@LogInfo(logType=LogType.查询,operationContent="查询用户预约的房源")
	@RequestMapping("getUr")
	@ResponseBody
	public List<Map<String,Object>> getUserReservation(HttpServletRequest request){
		String userId = request.getSession().getAttribute("userId")+"";
		return userHouseService.getUserReservation(userId);
	}
	
	@LogInfo(logType=LogType.修改,operationContent="取消预约")
	@RequestMapping("abolishSub")
	@ResponseBody
	public int abolishSub(HttpServletRequest request){
		return userHouseService.abolishSub(request.getParameter("id"),request.getParameter("sign"));
	}
	
	@LogInfo(logType=LogType.新增,operationContent="帮我找房")
	@RequestMapping("searchH")
	@ResponseBody
	public int searchHouse(HttpServletRequest request){
		return userHouseService.searchHouse(request);
	}
	
	@LogInfo(logType=LogType.查询,operationContent="查询三套猜用户喜欢的房间")
	@RequestMapping("yhxhd")
	@ResponseBody
	public List<Map<String,Object>> searchYhxhd(HttpServletRequest request){
		
		return userHouseService.searchYhxhd(request);
	}
	
}
